package com.example.image

import kotlin.math.round
//建造者设计模式
class ImageOptions private constructor(
    val placeImage:Int,
    val errorImage:Int,
    val isGifImage:Boolean,
    val imgSize:IntArray,
    val skipMemoryCache:Boolean,
    val skipDiskCache:Boolean,
    val isCircle:Boolean,
    val roundRadius:Int
) {

    companion object Builder{
        private var placeImage = 0
        private var errorImage = 0
        private var isGifImage = false
        private var imgSize = intArrayOf()
        private var skipMemoryCache = false
        private var skipDiskCache = false
        private var isCircle = false
        private var roundRadius =  0

        fun placeImage(placeImage: Int):Builder{
            this.placeImage = placeImage
            return this
        }
        fun errorImage(errorImage: Int):Builder{
            this.errorImage = errorImage
            return this
        }
        fun isGifImage(isGifImage: Boolean):Builder{
            this.isGifImage = isGifImage
            return this
        }
        fun imgSize(imgSize: IntArray):Builder{
            this.imgSize = imgSize
            return this
        }
        fun skipMemoryCache(skipMemoryCache: Boolean):Builder{
            this.skipMemoryCache = skipMemoryCache
            return this
        }
        fun skipDiskCache(skipDiskCache: Boolean):Builder{
            this.skipDiskCache = skipDiskCache
            return this
        }
        fun isCircle(isCircle: Boolean):Builder{
            this.isCircle = isCircle
            return this
        }
        fun roundRadius(roundRadius: Int):Builder{
            this.roundRadius = roundRadius
            return this
        }
        fun build():ImageOptions{
            return ImageOptions(placeImage, errorImage, isGifImage,
                imgSize, skipMemoryCache, skipDiskCache, isCircle, roundRadius)
        }
    }
}